package com.ge.pp;

import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

public class PPImage {
	public int id;
	public String desc;
	public String path;
	public byte[] data;
	public BufferedImage bi;	
	
	public PPImage(int _id, String _desc, String _path) {
		id = _id;
		desc = _desc;
		path = _path;
	}
	/*
     * Ravi    :    Checked module
     */
	public void LoadImageData() throws IOException 
	{		
		System.out.println(" in LoadImageData ");
		try 
		{
			File f = new File(path);
			if (f.exists()) 
			{
				FileInputStream fis = new FileInputStream(f);
				long size = f.length();
				data = new byte[(int) size];
				fis.read(data);
				fis.close();
			} 
			else 
			{
				data = null;
			}			
		} 
		catch (IOException e) 
		{			
			throw e;
		}
	}
	public String toString() {
		return desc;
	}
    /*
     * Ravi    :    Checked module
     */
	public void createImageFromData() throws IOException 
	{
		try 
		{
			System.out.println("in createImageFromData");
			bi = ImageIO.read(new ByteArrayInputStream(data));
		} 
		catch (IOException e) 
		{			
			throw e;
		}		
	}
	
}
